package com.itheima.test21;

import com.itheima.test16.Student;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ObjectStream {
    public static void main(String[] args) throws Exception {
        ObjectOutputStream oos =
                new ObjectOutputStream(new FileOutputStream("test01\\stu.txt"));
        Student stu = new Student("张三",13);
        oos.writeObject(stu);
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        ObjectInputStream ois =
                new ObjectInputStream(new FileInputStream("stu.txt"));
        Student student = (Student) ois.readObject();
        System.out.println(student);
    }
}
